package com.yangyang.hw3hbase.controller;

import com.yangyang.hw3hbase.service.HBaseService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class HBaseController {

    @Resource
    private HBaseService hBaseService;

    @RequestMapping(value = "test")
    public void test(){

        String tableName = "yangyang";
        String fm = "student";
        boolean exist = hBaseService.exist(tableName);
        if (exist){
            hBaseService.deleteTable(tableName);
        }

        hBaseService.createTable(tableName, fm);

        hBaseService.putData();

        List<Map<String, String>> all = hBaseService.getAll(tableName);

        System.out.println(all);

        hBaseService.deleteRow(tableName, "row1", "row2");

        List<Map<String, String>> all2 = hBaseService.getAll(tableName);

        System.out.println(all2);
    }


}
